#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>

using namespace std;

int main()
{
	int arr[5];
	int num = 0;
	for (int i = 0; i < 5; i++)
	{
		cin >> arr[i];

		int a = arr[i] / 1000;
		int b = (arr[i] / 100) % 10;
		int c = (arr[i] / 10) % 10;
		int d = arr[i] % 10;

		if (a == b && d == b + 1)
		{
			num++;
		}
	}
	
	cout << num << endl;
	return 0;
}